package com.secondkill.redis;

/**
 * Created by IBM on 2018/7/4.
 */
public abstract class BaseRedisKeyPrefix implements RedisKeyPrefix{

    private int expireSeconds;
    private String prefix;

    public BaseRedisKeyPrefix(String prefix) {
        this.expireSeconds = 0; // 默认永远不过期
        this.prefix = prefix;
    }

    public BaseRedisKeyPrefix(int expireSeconds, String prefix) {
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;
    }

    @Override
    public String getPrefix() {
        String realPrefix = getClass().getName() + ":" + prefix;
        return realPrefix;
    }

    @Override
    public int expireSeconds() {
        return expireSeconds;
    }
}
